<template>
  <div class="wh-100 fs-12 overflow-hidden" style="background-color: #fff">
    <div class="w-100 overflow-auto head-box">
      <!--title&返回-->
      <div class="d-flex-between-center px-20 head-box01">
        <div class="fs-16 fw-7">{{ model === 'add' ? '添加帮扶对象' : '修改帮扶对象' }}</div>
        <Button @click="goBack()">返回</Button>
      </div>
      <!--基本信息-->
      <Tooltip placement="top" content="编辑模式下不允许修改帮扶类别" :disabled="model === 'add'">
        <Form :rules="essentialInformationFormVali" ref="essentialInformationRef" :model="essentialInformationForm"
              :label-width="labelWidth100" class="d-flex mt-24">
          <div class="ml-20">
            <FormItem label="身份证号" prop="idCard" class="form-item-width">
              <Input v-if="model === 'add'" @on-blur="getDetailDataByIdCard" v-model="essentialInformationForm.idCard"
                     placeholder="请输入学生身份证号，自动获取其信息"></Input>
              <Input v-else-if="model === 'edit'" :disabled="model === 'edit'" v-model="essentialInformationForm.idCard"
                     placeholder="请输入学生身份证号"></Input>
            </FormItem>
            <FormItem label="姓名" prop="name" class="form-item-width">
              <Input :disabled="isDisabled('name') || model === 'edit'"
                     v-model="essentialInformationForm.name"
                     placeholder="请输入学生姓名">
              </Input>
            </FormItem>
            <FormItem label="性别" prop="sex" class="form-item-width">
              <RadioGroup v-model="essentialInformationForm.sex">
                <Radio :disabled="isDisabled('sex') || model === 'edit'" label="1">男</Radio>
                <Radio :disabled="isDisabled('sex') || model === 'edit'" label="2">女</Radio>
              </RadioGroup>
            </FormItem>
            <FormItem label="出生日期" prop="birthday" class="form-item-width">
              <DatePicker
                  :options="options"
                  :disabled="isDisabled('birthday') || model === 'edit'"
                  style="width: 100%"
                  type="date"
                  placeholder="请选择日期"
                  format="yyyy/MM/dd"
                  v-model="essentialInformationForm.birthday"
              ></DatePicker>
            </FormItem>
            <FormItem label="民族" prop="ethnic" class="form-item-width">
              <Select :disabled="isDisabled('ethnic') || model === 'edit'" v-model="essentialInformationForm.ethnic"
                      placeholder="请选择民族" style="width: 100%">
                <Option v-for="item in formTypeMap.ethnic" :value="item.value" :key="item.value">
                  {{ item.title }}
                </Option>
              </Select>
            </FormItem>
            <FormItem label="联系方式" prop="mobile" class="form-item-width">
              <Input :disabled="isDisabled('mobile') || model === 'edit'" v-model="essentialInformationForm.mobile"
                     placeholder="请输入学生手机号"></Input>
            </FormItem>
            <FormItem label="家庭电话" prop="homeMobile" class="form-item-width">
              <Input :disabled="isDisabled('homeMobile') || model === 'edit'"
                     v-model="essentialInformationForm.homeMobile" placeholder="请输入手机号码"></Input>
            </FormItem>
          </div>
          <div class="ml-100">
            <FormItem label="所属院系" prop="college" class="form-item-width">
              <AutoComplete
                  :disabled="isDisabled('college') || model === 'edit'"
                  v-model="essentialInformationForm.college"
                  icon="ios-search"
                  placeholder="请选择所属院系"
                  style="width: 100%"
              >
                <Option v-for="item in formTypeMap.college" :value="item.yxname" :key="item.yxname">
                  {{ item.yxname }}
                </Option>
              </AutoComplete>
            </FormItem>
            <FormItem label="学历层次" prop="educationalLevel" class="form-item-width">
              <Input
                  :disabled="isDisabled('educationalLevel') || model === 'edit'"
                  style="width: 100%"
                  placeholder="请填写学历层次"
                  v-model="essentialInformationForm.educationalLevel"
              ></Input>
            </FormItem>
            <FormItem label="专业" prop="profession" class="form-item-width">
              <Input
                  v-model="essentialInformationForm.profession"
                  :disabled="essentialInformationForm.educationalLevel === ''  || isDisabled('profession') || model === 'edit'"
                  placeholder="请填写专业"
              ></Input>
            </FormItem>

            <FormItem label="政治面貌" prop="politicalStatus" class="form-item-width">
              <Select :disabled="isDisabled('politicalStatus') || model === 'edit'"
                      v-model="essentialInformationForm.politicalStatus"
                      placeholder="请选择政治面貌" style="width: 100%">
                <Option v-for="item in formTypeMap.political" :value="item.value" :key="item.value">
                  {{ item.title }}
                </Option>
              </Select>
            </FormItem>
            <FormItem label="毕业时间" prop="graduationTime" class="form-item-width">
              <DatePicker
                  style="width: 100%"
                  type="date"
                  :disabled="isDisabled('graduationTime') || model === 'edit'"
                  placeholder="请选择日期"
                  format="yyyy/MM/dd"
                  v-model="essentialInformationForm.graduationTime"
              ></DatePicker>
            </FormItem>
            <FormItem label="家庭联系人" prop="familyContact" class="form-item-width">
              <Input :disabled="isDisabled('familyContact') || model === 'edit'"
                     v-model="essentialInformationForm.familyContact" placeholder="请输入家庭联系人"></Input>
            </FormItem>
          </div>
        </Form>
      </Tooltip>

      <!--标记帮扶类别-->
      <div class="px-20 title mt-20">
        <div class="fs-16 fw-7">标记帮扶类别</div>
      </div>
      <!--            编辑模式下不允许修改帮扶分类-->
      <Tooltip placement="top" content="编辑模式下不允许修改帮扶类别" :disabled="model === 'add'">
        <CheckboxGroup class="mt-36 ml-20" v-model="helpCategory">
          <Checkbox :disabled="isDisabled('helpCategory') || model === 'edit'" v-for="item in helpCategorySelect"
                    :label="item" :key="item">
            <span>{{ item }}</span>
          </Checkbox>
        </CheckboxGroup>
      </Tooltip>

      <!--添加帮扶人-->
      <div class="px-20 mt-20 title">
        <div class="fs-16 fw-7">添加帮扶人</div>
      </div>
      <Form :rules="addHelpersFormVali" :model="addHelpersForm" ref="addHelpersRef" :label-width="labelWidth120" inline
            class="ml-20 mt-28">
        <row v-show="dataCheckConditionForm.knqtbj == 0">
          <FormItem label="帮扶人姓名" class="w400" >
            <Input :disabled="isDisabled('helperName')" v-model="addHelpersForm.helperName"></Input>
          </FormItem>
          <FormItem label="帮扶人职务" class="w400" >
            <Input :disabled="isDisabled('helperJob')" v-model="addHelpersForm.helperJob"></Input>
          </FormItem>
          <FormItem label="联系电话" class="w400">
            <Input :disabled="isDisabled('helperPhone')" v-model="addHelpersForm.helperPhone"></Input>
          </FormItem>
        </row>
        <row v-show="dataCheckConditionForm.knqtbj != 0">
          <FormItem prop="helperName" label="帮扶人姓名" class="w400" >
            <Input :disabled="isDisabled('helperName')" v-model="addHelpersForm.helperName"></Input>
          </FormItem>
          <FormItem prop="helperJob" label="帮扶人职务" class="w400" >
            <Input :disabled="isDisabled('helperJob')" v-model="addHelpersForm.helperJob"></Input>
          </FormItem>
          <FormItem prop="helperPhone" label="联系电话" class="w400" >
            <Input :disabled="isDisabled('helperPhone')" v-model="addHelpersForm.helperPhone"></Input>
          </FormItem>
        </row>

      </Form>
      <!--数据核对情况-->
      <div class="px-20 mt-20 title">
        <div class="fs-16 fw-7">数据核对情况</div>
      </div>
      <Form :rules="dataCheckConditionVali" :model="dataCheckConditionForm" ref="dataCheckCondition"
            :label-width="labelWidth140" inline class="ml-20 mt-28">
        <div>
          <FormItem prop="dataCheckCondition" label="困难群体标记" class="form-item-width">
            <Select @on-change="knqtbjCheckConditionChange"
                    :disabled="!knqtbjSwitch || isDisabled('dataCheckCondition')"
                    v-model="dataCheckConditionForm.knqtbj">
              <Option v-for="item in knqtbjList" :value="item.value" :disabled="item.disable">
                {{ item.label }}
              </Option>
            </Select>
          </FormItem>
          <FormItem prop="dataCheckCondition" label=" 添加数据不一致原因" class="form-item-width"
                    v-show="!dataCheckConditionForm.knqtbj">
            <Select @on-change="handleDataCheckConditionChange" :disabled="isDisabled('dataCheckCondition')"
                    v-model="dataCheckConditionForm.dataCheckCondition">
              <Option v-for="item in dataCheckConditionSelect" :value="item.value" :disabled="item.disable"
                      :key="item.value">
                {{ item.label }}
              </Option>
            </Select>
          </FormItem>
          <FormItem prop="dataCheckOther" label="其他原因" class="form-item-width"
                    v-show="!dataCheckConditionForm.knqtbj">
            <Input
                :disabled="dataCheckConditionForm.dataCheckCondition !== '其他' || isDisabled('dataCheckOther')"
                type="textarea"
                :rows="4"
                v-model="dataCheckConditionForm.dataCheckOther"
            ></Input>
          </FormItem>
        </div>
      </Form>

      <!--添加帮扶措施-->
      <div class="d-flex-between-center px-20 mt-100 title">
        <div class="fs-16 fw-7">添加帮扶措施</div>
        <div>
          <Button type="primary" @click="showModel()">谈心谈话</Button>

          <Button style="background-color: #fff" @click="showModel1()">参加就业促进活动</Button>
          <Button style="background-color: #fff" @click="showModel2()">推荐岗位</Button>
          <Button style="background-color: #fff" @click="showModel3()">其他帮扶措施</Button>
        </div>
      </div>
      <div class="pl-100 w-90 mb-100">
        <!--谈心谈话-->
        <div>
          <div class="d-flex-align-center mt-12">
            <img class="w25" src="./images/information.png" />
            <div class="ml-12 color-size">谈心谈话</div>
          </div>
          <div class="ml-12 w-100 bl2">
            <span v-if="listOfHeartToHeartTalks.length <= 0" class="ml-24 label02">还未添加谈心谈话记录</span>
            <div v-for="(item, index) in listOfHeartToHeartTalks" :key="index">
              <div class="ml-24 mt-12 w900">
                <div class="d-flex-between-center px-12 h40">
                  <div class="fw-7">第{{ index + 1 }}次谈话</div>
                  <div>
                    <Icon size="16" color="#328bfb" type="md-create" @click="showModel(index)" />
                    <Icon v-if="model === 'add'" @click="deleteAConversation(index)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                    <!--当为修改模式时 删除修改数据库-->
                    <Icon v-else-if="model === 'edit'" @click="deleteHeart(item.id)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                  </div>
                </div>
                <div class="w-100 px-12 fs-12 mt-12" style="word-wrap: break-word">
                  {{ item.conversation }}
                </div>
                <div style="color: #899098" class="fs-12 d-flex-between-center mt-12 px-12">
                  <div>地点：{{ item.place }} ｜ 时间：{{ item.date && moment(item.date).format('YYYY-MM-DD HH:mm') }}
                  </div>
                  <div v-show="model === 'edit'">创建时间：{{ item.createTime }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!--参加就业促进活动-->
        <div>
          <div class="d-flex-align-center mt-12">
            <img class="img01" src="./images/plan.png" />
            <div class="ml-12 label01">参加就业促进活动</div>
          </div>
          <div class="ml-12 w-100 class01">
            <span v-if="participationInEmploymentPromotionActivitiesList.length <= 0" class="ml-24 label02">还未添加参加就业促进活动情况</span>
            <div v-else v-for="(item, index) in participationInEmploymentPromotionActivitiesList" :key="index">
              <div class="ml-24 mt-12 class02">
                <div class="d-flex-between-center px-12 h40">
                  <div class="fw-7">第{{ index + 1 }} 次活动</div>
                  <div>
                    <Icon @click="showModel1(index)" size="16" color="#328bfb" type="md-create" />
                    <Icon v-if="model === 'add'" @click="deleteAConversation1(index)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                    <Icon v-else-if="model === 'edit'" @click="deleteEmploy(item.id)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                  </div>
                </div>
                <div class="w-100 px-12 fs-12 mt-12" style="word-wrap: break-word">
                  活动名称:{{ item.nameOfActivity }}
                  <br />
                  参加时间:{{ item.participationTime && moment(item.participationTime).format('YYYY-MM-DD HH:mm') }}
                </div>
                <div style="color: #899098" class="fs-12 d-flex justify-content-end mt-12 px-12">
                  <div v-show="model === 'edit'">创建时间：{{ item.createTime }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!--推荐岗位-->
        <div>
          <div class="d-flex-align-center mt-12">
            <img class="img01" src="./images/recommend.png" />
            <div class="ml-12 label01">推荐岗位</div>
          </div>

          <div class="ml-12 w-100 bl2">
            <span v-if="recommendedPostList.length <= 0" class="ml-24 label02">还未添加参加就业促进活动情况</span>
            <div v-else v-for="(item, index) in recommendedPostList" :key="index">
              <div class="ml-24 mt-12 w900">
                <div class="d-flex-between-center px-12" style="height: 40px; border-bottom: 1px solid #e8edf4">
                  <div class="fw-7">第{{ index + 1 }}次谈话</div>
                  <div>
                    <Icon @click="showModel2(index)" size="16" color="#328bfb" type="md-create" />
                    <Icon v-if="model === 'add'" @click="deleteAConversation2(index)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                    <Icon v-else-if="model === 'edit'" @click="deleteRecommend(item.id)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                  </div>
                </div>
                <div class="w-100 px-12 fs-12 mt-12" style="word-wrap: break-word">
                  <div>单位名称：{{ item.companyName }}</div>
                  <div>岗位名称：{{ item.nameOfThePost }}</div>
                  <div>单位联系人：{{ item.unitContact }}</div>
                  <div>联系方式：{{ item.contactWay }}</div>
                </div>
                <div style="color: #899098" class="fs-12 d-flex-between-center mt-12 px-12">
                  <div>是否签约：{{ item.whetherToSignOrNot === '1' ? '是' : '否' }} ｜
                    时间：{{ item.recommendedTime && moment(item.recommendedTime).format('YYYY-MM-DD HH:mm:ss') }}
                  </div>
                  <div v-show="model === 'edit'">创建时间：{{ item.createTime }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!--其他措施-->
        <div>
          <div class="d-flex-align-center mt-12">
            <img class="img01" src="./images/sign.png" />
            <div class="ml-12 label01">有其他有效措施，可以继续补充</div>
          </div>
          <div class="ml-12 w-100 class01">
            <div v-for="(item, index) in otherMeasuresList" :key="index"  v-if="otherMeasuresList.length  > 0">
              <div class="ml-24 mt-12 w900">
                <div class="d-flex-between-center px-12 h40">
                  <div class="fw-7">其他措施</div>
                  <div>
                    <Icon @click="showModel3(index)" size="16" color="#328bfb" type="md-create" />
                    <Icon v-if="model === 'add'" @click="deleteAConversation3(index)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                    <Icon v-else-if="model === 'edit'" @click="deleteOther(otherId)" class="ml-12" size="16"
                          color="#328bfb" type="ios-trash-outline" />
                  </div>
                </div>
                <div class="w-100 px-12 fs-12 mt-12" style="word-wrap: break-word">
                  {{ item.otherMeasuresText }}
                </div>
                <div style="color: #899098" class="fs-12 d-flex justify-content-end mt-12 px-12">
                  <div v-show="model === 'edit'">创建时间：{{ item.createTime }}</div>
                </div>
              </div>
            </div>
            <span v-else class="ml-24 label02">还未添加谈心谈话记录</span>
          </div>
        </div>
      </div>
      <!--添加帮扶结果-->
      <div class="px-20 mt-12 title">
        <div class="fs-16 fw-7">添加帮扶结果</div>
      </div>
      <Form class="ml-20 mt-20" :rules="addHelpResultsFormVali" :model="addHelpResultsForm" ref="addHelpResultsRef"
            :label-width="labelWidth100">
        <!--当选择已落实毕业去向的时候显示这个-->
        <template v-if="addHelpResultsForm.helpResult === '1'">
          <FormItem prop="employmentStatus" label="就业状况" class="w300">
            <Select disabled v-model="addHelpResultsForm.employmentStatus" placeholder="请选择就业状况"
                    @on-change="getEmploymentCategoryByStatus">
              <Option v-for="item in formTypeMap.employmentStatus" :value="item.value" :key="item.id">
                {{ item.title }}
              </Option>
            </Select>
          </FormItem>
          <FormItem label="就业类别" class="form-item-width">
            <div class="d-flex-align-center">
              <Select
                  class="w200"
                  v-model="addHelpResultsForm.employmentCategoryOne"
                  placeholder="请选择就业类型"
                  :loading="employmentCategoryOneLoading"
                  disabled
                  @on-change="setEmploymentCategoryTwoSelect"
              >
                <Option v-for="item in employmentCategoryOne" :value="item.title" :key="item.id">
                  {{ item.title }}
                </Option>
              </Select>
              <Select
                  v-model="addHelpResultsForm.employmentCategoryTwo"
                  :placeholder="employmentCategoryTwo.des"
                  disabled
                  :loading="employmentCategoryTwoLoading"
              >
                <Option v-for="item in employmentCategoryTwo.list" :value="item.id" :key="item.id">
                  {{ item.title }}
                </Option>
              </Select>
            </div>
          </FormItem>
          <FormItem label="单位名称" prop="enterpriseName" class="form-item-width">
            <Input disabled v-model="addHelpResultsForm.enterpriseName" placeholder="请输入单位名称"></Input>
          </FormItem>
          <FormItem label="落实时间" prop="implementationTime" class="w300">
            <DatePicker disabled type="date" placeholder="请选择日期" v-model="addHelpResultsForm.implementationTime"
                        format="yyyy/MM/dd"></DatePicker>
          </FormItem>
        </template>
        <!--当选择未落实毕业去向的时候选择这个-->
        <template v-else>
          <FormItem label="未落实原因" prop="unImplementationReason" class="w600">
            <Input placeholder="请填写未落实原因 （最多200字）" type="textarea" show-word-limit :maxlength="200"
                   :rows="10" v-model="addHelpResultsForm.unImplementationReason"></Input>
          </FormItem>
        </template>
        <FormItem label="帮扶结果" prop="helpResult">
          <RadioGroup v-model="addHelpResultsForm.helpResult" @on-change="handleHelpResultChange">
            <Radio label="1" disabled>已落实毕业去向</Radio>
            <Radio label="0" disabled>未落实毕业去向</Radio>
          </RadioGroup>
        </FormItem>
      </Form>
    </div>
    <div class="d-flex-center" style="height: 60px">
      <Button class="w100" style="background-color: #fff;" @click="goBack()">取消</Button>
      <Button v-if="model === 'add'" type="primary" @click="handleSubmit"

              class="w100">提交
      </Button>
      <Button v-else-if="model === 'edit'" type="primary" @click="editBasic">保存修改信息</Button>
    </div>
    <!--谈心谈话弹窗-->
    <el-dialog title="谈心谈话记录" :close-on-click-modal="false" :close-on-press-escape="false"
               :visible.sync="heartToHeartTalk">
      <Form ref="heartToHeartTalkRef" :model="heartToHeartTalkForm" :label-width="labelWidth100">
        <FormItem label="地点" class="w400">
          <Input placeholder="请输入地点" v-model="heartToHeartTalkForm.place"></Input>
        </FormItem>
        <FormItem label="日期">
          <DatePicker v-model="heartToHeartTalkForm.date" type="datetime" placeholder="请选择日期"
                      class="w200"></DatePicker>
        </FormItem>
        <FormItem label="谈话内容" class="w600">
          <Input placeholder="请填写未落实原因 （最多200字）" type="textarea" show-word-limit :maxlength="200" :rows="10"
                 v-model="heartToHeartTalkForm.conversation"></Input>
        </FormItem>
      </Form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="heartToHeartTalk = false">取 消</el-button>
                <el-button v-if="model === 'add'" type="primary" @click="submitAHeartToHeartTalk">确 定</el-button>
                <el-button v-else-if="model === 'edit'" type="primary" @click="editHeart">确 定</el-button>
            </span>
    </el-dialog>
    <!--参加就业促进活动情况弹窗-->
    <el-dialog title="参加就业促进活动情况" :close-on-click-modal="false" :close-on-press-escape="false"
               :visible.sync="participationInEmploymentPromotionActivities">
      <Form ref="participationInEmploymentPromotionActivitiesRef"
            :model="participationInEmploymentPromotionActivitiesForm" :label-width="labelWidth100">
        <FormItem label="活动名称" class="w600">
          <Input placeholder="请输入地点"
                 v-model="participationInEmploymentPromotionActivitiesForm.nameOfActivity"></Input>
        </FormItem>
        <FormItem label="日期">
          <DatePicker v-model="participationInEmploymentPromotionActivitiesForm.participationTime" type="datetime"
                      placeholder="请选择日期" class="w200"></DatePicker>
        </FormItem>
      </Form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="participationInEmploymentPromotionActivities = false">取 消</el-button>
                <el-button v-if="model === 'add'" type="primary"
                           @click="employmentPromotionActivities">确 定</el-button>
                <el-button v-else-if="model === 'edit'" type="primary" @click="editEmploy">确 定</el-button>
            </span>
    </el-dialog>
    <!--推荐岗位-->
    <el-dialog title="推荐岗位" :close-on-click-modal="false" :close-on-press-escape="false"
               :visible.sync="recommendedPost">
      <Form ref="recommendedPostRef" :model="recommendedPostForm" :label-width="labelWidth100">
        <FormItem label="单位名称" class="w600">
          <Input placeholder="请输入" v-model="recommendedPostForm.companyName"></Input>
        </FormItem>
        <FormItem label="岗位名称" class="w600">
          <Input placeholder="请输入" v-model="recommendedPostForm.nameOfThePost"></Input>
        </FormItem>
        <FormItem label="单位联系人" class="w600">
          <Input placeholder="请输入" v-model="recommendedPostForm.unitContact"></Input>
        </FormItem>
        <FormItem label="联系方式" class="w600">
          <Input placeholder="请输入" v-model="recommendedPostForm.contactWay"></Input>
        </FormItem>
        <FormItem label="推荐时间">
          <DatePicker v-model="recommendedPostForm.recommendedTime" type="datetime" placeholder="请选择日期"
                      class="w200"></DatePicker>
        </FormItem>
        <FormItem label="是否签约" class="w600">
          <RadioGroup v-model="recommendedPostForm.whetherToSignOrNot">
            <Radio label="1">
              <span>是</span>
            </Radio>
            <Radio label="0">
              <span>否</span>
            </Radio>
          </RadioGroup>
        </FormItem>
      </Form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="recommendedPost = false">取 消</el-button>
                <el-button v-if="model === 'add'" type="primary" @click="recommendedPostSubmission">确 定</el-button>

                <el-button v-else-if="model === 'edit'" type="primary" @click="editRecommend">确 定</el-button>
            </span>
    </el-dialog>
    <!--其他措施-->
    <el-dialog title="其他措施" :close-on-click-modal="false" :close-on-press-escape="false"
               :visible.sync="otherMeasures">
      <Input :minlength="100" show-word-limit v-model="otherMeasuresText" type="textarea" :rows="10"
             placeholder="请填写其他措施（不少于100字）" />
      <span slot="footer" class="dialog-footer">
                <el-button @click="otherMeasures = false">取 消</el-button>
                <el-button v-if="model === 'add'" type="primary"
                           @click="otherAssistanceMeasuresToSubmit">确 定</el-button>
                <el-button v-else-if="model === 'edit'" type="primary" @click="editOther">确 定</el-button>
            </span>
    </el-dialog>


    <Modal v-model="errorModal" title="数据核对情况" width="800" :closable='false'>
      <Alert type="error" STYLE="color: red">未获取该学生的生源信息，请核对学生的生源信息，帮扶对象无生源学生无法进行困难群体标记!</Alert>
      <Form :model="errorForm" label-position="right" :label-width="labelWidth200" class="ml-20 mt-28">
        <FormItem label="添加数据不一致原因" class="w400">
          <Select v-model="errorForm.dataCheck">
            <Option v-for="item in dataCheckConditionSelect" :value="item.label" :disabled="item.disable"
                    :key="item.label">
              {{ item.value }}
            </Option>
          </Select>
        </FormItem>
        <FormItem label="其他原因" class="w400">
          <Input
              type="textarea"
              :rows="4"
              v-model="errorForm.dataCheckOther"
          ></Input>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button style="background-color: white" @click="goBack">取消</Button>
        <!--<Button type="primary" :loading="errorModalLoading" @click="goBack">确定</Button>-->
        <Button type="primary" :loading="errorModalLoading" @click="clickErrorModal">确定</Button>

      </div>
    </Modal>
  </div>
</template>

<script>
import moment from 'moment';
import { copy } from '@/util/ObjectUtil';
import {
  addHardshipSupport,
  addHeartTalk,
  deleteHeartTalk,
  deleteRecommend,
  editHeartTalk,
  getAllProfession,
  getDetailByIdCard,
  getEmploymentCategory,
  getHardshipSupportById,
  getSelectMap,
  updateHardshipSupport,
  deleteEmploy,
  editEmploy,
  addEmploy,
  addRecommend,
  editRecommend,
  addOther,
  editOther,
  deleteOther,
  getJyqx,
  getNoSourceMessage
} from '@/api/hardshipSupport';
import valiData, { addHelpResultsFormVali1, addHelpResultsFormVali2 } from './vali.js';
import { getTitleByValue } from '@/views/hardshipSupport/util';
import { addHelpersData } from '@/views/hardshipSupport/data';
import Cookies from 'js-cookie';
import { editDataCheck } from '../../api/hardshipSupport';

export default {
  computed: {
    moment() {
      return moment;
    },
    addHelpResultsFormVali() {
      if (this.addHelpResultsForm.helpResult === '1') {
        return addHelpResultsFormVali1;
      } else {
        return addHelpResultsFormVali2;
      }
    },
    helperName () {
      // 动态返回要校验的属性名，如果不需要校验则为空字符串
      return this.dataCheckConditionForm.knqtbj  ? 'helperName' : '';
    }
  },
  data() {
    return {
      pageIndex:1,
      labelWidth140: 140,
      labelWidth120: 120,
      labelWidth200: 200,
      labelWidth100: 100,
      errorModal: false,
      errorModalLoading: false,
      errorForm: {},
      id: 0,
      model: 'add', // add or edit
      options: {
        disabledDate(date) {
          return date && date.valueOf() > Date.now();
        }
      },
      knqtbjList: [
        { value: 1, label: '是', disable: false },
        { value: 0, label: '否', disable: false }
        // {value:-1,label:'待定',disable:false},
      ],
      // 所有数据
      ...addHelpersData,

      // 表单映射规则 用于下拉框的映射
      formTypeMap: {
        sex: [],
        ethnic: [],
        eduLevelType: [],
        political: [],
        college: [],
        employmentStatus: [] // 就业状态
      },
      // 帮扶类别 数据
      helpCategory: [],
      // 帮扶类别 所有选项
      helpCategorySelect: [
        '脱贫家庭学生',
        '脱贫不稳定学生',
        '边缘易致贫学生',
        '突发严重困难学生',
        '城乡低保学生',
        '特困救助学生',
        '孤儿学生',
        '残疾学生',
        '事实无人抚养',
        '低保边缘家庭学生',
        '支出型困难家庭学生',
        '其他低收入家庭学生'
      ],
      // 数据核对情况中的下拉列表
      dataCheckConditionSelect: [
        { value: '困难类型标记不一致', label: '困难类型标记不一致', disable: false },
        { value: '延迟毕业学生', label: '延迟毕业学生', disable: false },
        { value: '退学学生', label: '退学学生', disable: false },
        { value: '休学学生', label: '休学学生', disable: false },
        { value: '非困难群体毕业生', label: '非困难群体毕业生', disable: false },
        { value: '其他', label: '其他', disable: false }
      ],
      // dataCheckConditionSelect: ['困难类型标记不一致', '延迟毕业学生', '退学学生', '休学学生', '非困难群体毕业生', '其他'],
      dataCheckConditionForm: {
        dataCheckCondition: '',
        dataCheckOther: ''
      },
      // 就业类别下拉框 因为就业类别需要根据就业状况来判断 这里的状态只维持下拉框的状态 不管表单内容 联动表单
      employmentCategoryOne: [],
      employmentCategoryTwo: [], // 二级联动菜单 但是可能用不到
      // 上面两个表单的loading
      employmentCategoryOneLoading: false,
      employmentCategoryTwoLoading: false,
      // 专业选择 级联 全部数据 不参与页面渲染
      professionSelectData: [],
      // 页面渲染时用这个数据 这个数据是上面的分片来的
      professionSelectForm: [],
      // 标记专业选项框能不能用
      professionSelectEnable: true,
      knqtbjSwitch: false,
      // 接下来是验证字段
      ...valiData
    };
  },
  watch: {
    heartToHeartTalk(nv) {
      if (!nv) {
        this.$refs.heartToHeartTalkRef.resetFields();
        this.heartToHeartTalkForm = {
          conversation: '',
          place: '',
          date: '',
          id: ''
        };
      }
    },
    participationInEmploymentPromotionActivities(nv) {
      if (!nv) {
        this.$refs.participationInEmploymentPromotionActivitiesRef.resetFields();
        this.participationInEmploymentPromotionActivitiesForm = {
          nameOfActivity: '',
          participationTime: '',
          id: ''
        };
      }
    },
    recommendedPost(nv) {
      if (!nv) {
        this.$refs.recommendedPostRef.resetFields();
        this.recommendedPostForm = {
          companyName: '',
          nameOfThePost: '',
          unitContact: '',
          contactWay: '',
          recommendedTime: '',
          whetherToSignOrNot: '',
          id: ''
        };
      }
    },
    otherMeasures(nv) {
      if (!nv) {
        this.otherMeasuresText = '';
      }
    }
  },
  async mounted() {
    console.log(55);
    this.essentialInformationForm ={
      birthday: '', // yyyy-MM-dd
      college: '',
      educationalLevel: '',
      ethnic: '',
      graduationTime: '', // yyyy-MM-dd
      homeMobile: '', // 家庭手机号
      idCard: '', // 身份证号
      mobile: '', // 手机号
      name: '', // 姓名
      politicalStatus: '',
      profession: [], // 专业
      sex: '', // 男女
      studyCard: '', // 学号
      familyContact: '' // 家庭联系人
    }
    this.dataCheckConditionForm ={
      dataCheckCondition: '困难群体毕业生',
      dataCheckOther: ''
    }
    this.addHelpersForm ={
      helperName: '',
      helperJob: '',
      helperPhone: ''
    }
    this.addHelpResultsForm = {
      employmentCategoryOne: '',
      employmentCategoryTwo: '', // 详细
      employmentCategory: '',
      employmentStatus: '',
      implementationTime: '', // yyyy-MM-dd
      enterpriseName: '',
      helpResult: '1',
      unImplementationReason: '' // 当选择未落实毕业去向的时候 未落实原因
    };
    this.heartToHeartTalkForm = {
      place: '',
      date: '',
      conversation: '',
      id: 0,
      createTime: ''
    };
    this.participationInEmploymentPromotionActivitiesForm = {
      nameOfActivity: '',
      participationTime: '',
      id: 0,
      createTime: ''
    };
    this.recommendedPostForm = {
      companyName: '',
      nameOfThePost: '',
      unitContact: '',
      contactWay: '',
      recommendedTime: '',
      whetherToSignOrNot: '',
      id: 0,
      createTime: ''
    };
    this.errorForm= {}
    this.otherMeasuresText = '';
    this.listOfHeartToHeartTalks =[]
    // this.
    this.otherMeasuresList =[]
    console.log(6);
    this.onRestWindow();
    console.log(this.$route.query);
    window.addEventListener('resize', this.onRestWindow);
    this.getGnSet();
    // 判断页面
    let id = this.$route.query.id;
    this.pageIndex = this.$route.query?.pIndex || 1
    if (id) {
      // pageModel
      this.model = 'edit';
      this.id = id;
    }
    // loading
    const closeMsg = this.$Message.loading({
      duration: 0
    });
    await this.getMap();
    if (id) {
      // 继续获取
      let { result, code, success, message } = await getHardshipSupportById({
        id: id
      });
      if (message === '未查询到该学生的生源信息，请填写数据核对表单') {
        this.errorModal = true;
        this.getNoSourceMessage(id)
        closeMsg();
        // this.$Message.error('数据加载失败');
        return;
      }
      closeMsg();
      // 处理回显
      await this.handleEcho(result);
      setTimeout(() => {
        this.$Message.success('数据加载成功');
      }, 300);
    } else {
      setTimeout(() => {
        this.$Message.success('数据加载成功');
      }, 300);
    }
  },

  methods: {
    async getGnSet() {
      let res = await this.postRequest('/qyManage/getGnSet');
      if (res.success && res.result) {
        this.knqtbjSwitch = res.result.knqtbjSwitch;

      }
    },
    getNoSourceMessage(id){
      getNoSourceMessage({id}).then(res => {
        if (res.code === 200) {
          // this.errorForm.dataCheck=res.result.dataCheckCondition
          // this.errorForm.dataCheckOther=res.result.dataCheckOther
          this.$set(this.errorForm,'dataCheck',res.result.dataCheckCondition)
          this.$set(this.errorForm,'dataCheckOther',res.result.dataCheckOther)
        }
        console.log(this.errorForm);
      })
    },
    onRestWindow() {
      this.labelWidth140 = this.searchLabelWidth(this.labelWidth140);
      this.labelWidth120 = this.searchLabelWidth(this.labelWidth120);
      this.labelWidth200 = this.searchLabelWidth(this.labelWidth200);
      this.labelWidth100 = this.searchLabelWidth(this.labelWidth100);
    },
    clickErrorModal() {
      this.errorModalLoading = true;
      editDataCheck({ id: this.id, ...this.errorForm }).then(res => {
        if (res.success) {
          this.$Message.success('提交成功');
          this.errorModal = false;
          this.errorModalLoading = false;
          this.goBack()
        }
      });
    },
    async handleHelpResultChange() {
      if (this.addHelpResultsForm.helpResult === '1') {
        let res = await getJyqx({
          idCard: this.essentialInformationForm.idCard
        });
        if (res.code !== 200) {
          return;
        }
        console.log(res);
        const data = res.result;
        console.log(data);
        this.addHelpResultsForm.employmentStatus = data.employmentStatus;
        this.addHelpResultsForm.employmentCategory = data.employmentCategory;
        this.addHelpResultsForm.enterpriseName = data.enterpriseName;
        this.addHelpResultsForm.implementationTime = data.implementationTime;
        this.addHelpResultsForm.unImplementationReason = '';
        res = await this.getEmploymentCategoryByStatus();
        let { employmentCategory } = data;
        employmentCategory = employmentCategory + ''; // 转字符串
        // 测试
        console.log('需要找到的就业分类', employmentCategory);
        let done = false;
        for (let i = 0; i < res.length && !done; i++) {
          if (res[i].id === employmentCategory) {
            this.addHelpResultsForm.employmentCategoryOne = res[i].title;
            this.setEmploymentCategoryTwoSelect();
          }
          for (let i = 0; i < res.length && !done; i++) {
            if (res[i].profCode === employmentCategory) {
              this.addHelpResultsForm.employmentCategoryOne = res[i].title;
              this.addHelpResultsForm.employmentCategory = res[i].profCode;
              this.setEmploymentCategoryTwoSelect();
            }
            if (res[i].children) {
              // 递归查找
              for (let j = 0; j < res[i].children.length; j++) {
                if (res[i].children[j].profCode === employmentCategory) {
                  console.log(res[i].children[j].profCode, '找到了');
                  this.addHelpResultsForm.employmentCategoryOne = res[i].title;
                  this.setEmploymentCategoryTwoSelect();
                  this.addHelpResultsForm.employmentCategoryTwo = res[i].children[j].id;
                  this.addHelpResultsForm.employmentCategory = res[i].children[j].profCode;
                  done = true;
                  break;
                }
              }
            }
          }
        }
      }
    },
    isDisabled(prop) {
      // 当prop在disabledList中时返回true
      return this.disableProp.includes(prop);
    },
    knqtbjCheckConditionChange(e) {
      if (e == 0) {
        this.dataCheckConditionForm.dataCheckCondition = '';
        this.dataCheckConditionSelect = [
          // {value: '困难类型标记不一致',label:'困难类型标记不一致',disable:true },
          { value: '延迟毕业学生', label: '延迟毕业学生', disable: false },
          { value: '退学学生', label: '退学学生', disable: false },
          { value: '休学学生', label: '休学学生', disable: false },
          { value: '非困难群体毕业生', label: '非困难群体毕业生', disable: false },
          { value: '其他', label: '其他', disable: false }
        ];
      } else if (e == 1) {
        this.dataCheckConditionForm.dataCheckCondition = '';
        // if ( this.dataCheckConditionForm.dataCheckCondition == '非困难群体毕业生'){
        //     this.dataCheckConditionForm.dataCheckCondition = ''
        // }
        // this.dataCheckConditionSelect= [
        //     {value: '困难类型标记不一致',label:'困难类型标记不一致',disable:false },
        //     {value:'延迟毕业学生',label:'延迟毕业学生',disable:false },
        //     {value:'退学学生',label:'退学学生',disable:false },
        //     {value:'休学学生',label:'休学学生',disable:false },
        //     {value:'非困难群体毕业生',label:'非困难群体毕业生',disable:true },
        //     {value:'其他',label:'其他',disable:false }
        // ]

      } else {
        this.dataCheckConditionSelect = [
          { value: '困难类型标记不一致', label: '困难类型标记不一致', disable: false },
          { value: '延迟毕业学生', label: '延迟毕业学生', disable: false },
          { value: '退学学生', label: '退学学生', disable: false },
          { value: '休学学生', label: '休学学生', disable: false },
          { value: '非困难群体毕业生', label: '非困难群体毕业生', disable: false },
          { value: '其他', label: '其他', disable: false }
        ];
      }
    },
    handleDataCheckConditionChange(e) {
      if (e !== '其他') {
        this.dataCheckConditionForm.dataCheckOther = '';
      }
      // if (e == '非困难群体毕业生'){
      //     this.dataCheckConditionForm.knqtbj =  0
      //     this.knqtbjList=[
      //         {value:1,label:'是',disable:true},
      //         {value:0,label:'否',disable:false},
      //         // {value:-1,label:'待定',disable:true},1
      //     ]
      // }else {
      //     if ( this.dataCheckConditionForm.knqtbj == 1){
      //         this.dataCheckConditionForm.knqtbj =  1
      //     }
      //
      //     this.knqtbjList=[
      //        {value:1,label:'是',disable:false},
      //        {value:0,label:'否',disable:true},
      //        // {value:-1,label:'待定',disable:false},
      //
      //    ]
      // }
    },

    //<editor-fold desc="添加帮扶对象的方法">
    // 通过学历层次拿到所有的专业 三级层次 这是一个promise
    // 但是就算不拿他的结果也没关系 也会对页面产生反应
    // 一个用在表单change事件 更改学历层次后调用
    // 一个用在回显的时候用
    async getProfessionLevelOneByEduLevel() {
      const closeMsg = this.$Message.loading({
        content: '正在根据学历层次获取专业列表',
        duration: 0
      });
      // 下拉框不可用
      this.professionSelectEnable = false;
      this.professionSelectForm = [];
      this.professionSelectData = [];
      this.essentialInformationForm.profession = '';
      let gradLevelDict = this.essentialInformationForm.educationalLevel;
      let res = await getAllProfession(gradLevelDict);
      let data = await this.linkProfessionArray(res); // await也可以跟非promise

      this.professionSelectData = data;
      this.professionSelectForm = data.map(item => {
        if (item.children) {
          return {
            label: item.label,
            value: item.value,
            children: [],
            loading: false
          };
        } else {
          return {
            label: item.label,
            value: item.value
          };
        }
      });
      closeMsg();
      this.professionSelectEnable = true;
      // 这里返回res是为了给回显用 回显查找路径的时候需要用到三层数据
      return res;
    },

    // 将三层的数据连在一起
    linkProfessionArray(res) {
      // res是一个数组 每一个item又是一个数组
      // res[0]是父 res[1]是子 res[2]是孙
      // 子代的parentCode 和 父亲的profCode一致 帮我连接成一个数组 祖先中用children表示子代
      // 构建 profCode 到项的映射

      // 先做第一层
      let data = res[0].result;
      // 保存索引和profCode
      let mapOne = {};
      console.log(res);
      data = data.map((item, index) => {
        mapOne[item.profCode] = index;
        return {
          value: item.profCode,
          label: item.title,

          loading: false
        };
      });
      // 此时的data要作为选择器第一层

      // 做第二层
      let mapTwo = {};
      for (let i = 0; i < res[1].result.length; i++) {
        let item = res[1].result[i];
        let index1 = item.parentCode;
        let parent = data[mapOne[index1]];
        if (!parent) {
          continue;
        }
        if (!parent.children) {
          parent.children = [];
        }
        let parentItem = parent.children;

        // 拿到当前children的长度
        let index2 = parentItem.length;

        parentItem.push({
          value: item.profCode,
          label: item.title,

          loading: false
        });
        // 保存此时的索引和第二级的profCode
        mapTwo[item.profCode] = [mapOne[index1], index2];
      }

      // 第三层

      for (let i = 0; i < res[2].result.length; i++) {
        let item = res[2].result[i];
        // 从item中拿到parentCode
        let path = mapTwo[item.parentCode];
        if (!path) {
          continue;
        }
        let parent = data[path[0]].children[path[1]];
        if (!parent.children) {
          parent.children = [];
        }
        let parentItem = parent.children;

        parentItem.push({
          value: item.profCode,
          label: item.title
        });
      }

      Object.freeze(data);
      return data;
    },

    // 获取专业级联菜单 专业菜单方法 这个方法给组件的事件用
    getProfessionSelectDataSlice(item, callback) {
      item.loading = true;
      console.log(item);
      // 根据item.value
      let data = this.professionSelectData.find(i => {
        return i.value === item.value;
      });
      if (data.children) {
        // 如果存在子菜单
        this.professionSelectForm.map(i => {
          if (i.value === data.value) {
            i.children = data.children;
          } else {
            i.children = [];
          }
        });
      } else {
        delete item.loading;
        item.children = [];
      }
      item.loading = false;
      callback();
    },

    // 拿到映射关系 院系代码编号 民族编码 就业状态
    async getMap() {
      // 性别 民族 院系 专业 学历层次 政治面貌 就业状态
      let res = await getSelectMap(true);
      let formTypeMap = {
        sex: res[0].result,
        ethnic: res[1].result,
        eduLevelType: res[2].result,
        political: res[3].result,
        college: res[4].result,
        employmentStatus: res[5].result
      };
      this.formTypeMap = formTypeMap;
      console.log('下拉框数据', formTypeMap);
    },


    // 按照身份证查找基本信息 回显
    async getDetailDataByIdCard() {
      if (this.essentialInformationForm.idCard.length !== null ||
          this.essentialInformationForm.idCard.length !== '' ||
          this.essentialInformationForm.idCard.length !== 18) return;
      // 查询接口
      let res;

      try {
        res = await getDetailByIdCard({
          idCard: this.essentialInformationForm.idCard
        });
        if (res.code !== 200) {
          throw res.message;
        }
        if (Object.keys(res.result ?? {}).length === 0) {
          // 没有返回
          throw '没有返回结果';
        }
      } catch (e) {
        this.$Message.info(e);
        return;
      }
      // 遍历res.result的key 让能拿到的值disabled掉
      let tempL = [];
      Object.keys(res.result).forEach(item => {
        if (typeof res.result[item] === 'string') {
          if (item.length > 0) {
            tempL.push(item);
          }
        }
        // 如果是列表
        if (Array.isArray(res.result[item])) {
          if (res.result[item].length > 0) {
            tempL.push(item);
          }
        }
        // 如果是数字
        if (typeof res.result[item] === 'number') {
          if (res.result[item] !== 0) {
            tempL.push(item);
          }
        }
      });
      this.disableProp = tempL;

      // 将基本数据放入表单中
      for (let key in this.essentialInformationForm) {
        this.essentialInformationForm[key] = res.result[key];
      }

      /*for (let key in this.addHelpersForm) {
          this.addHelpersForm[key] = res.result[key] ? res.result[key] : '';
      }*/
      this.essentialInformationForm.sex = res.result.sex + '';
      // 单独判断一下学历层次的数值类型 如果学历层次和formTypeMap[2]的列表中的对象的title相等
      // 那么就将学历层次的值设置为这个对象的value
      this.essentialInformationForm.educationalLevel = res.result.educationalLevel + '';
      /*for (let i = 0; i < this.formTypeMap.eduLevelType.length; i++) {
          if (this.formTypeMap.eduLevelType[i].title === res.result.educationalLevel) {
              this.essentialInformationForm.educationalLevel = this.formTypeMap.eduLevelType[i].value;
              break;
          }
      }*/

      // 保存网络获取的数据
      const data = res.result;

      // 这个函数会清空专业列表 因为当通过更改学历层次选择专业的时候 需要将专业清空
      // 这个函数会把值写入data中
      //res = await this.getProfessionLevelOneByEduLevel();
      // 这里说明获取完了 给他赋值专业的内容
      // res就是专业名 接下来要在专业列表中找到res并且给出路径
      //this.essentialInformationForm.profession = this.getProfPathByProfCode(professionFromEcho, res);
      // 判断需不需要做就业类别的回显
      this.essentialInformationForm.profession = professionFromEcho;
      this.addHelpResultsForm.helpResult = data.helpResult ?? '0';
      this.addHelpResultsForm.helpResult += '';
      if (this.addHelpResultsForm.helpResult === '1') {
        // 需要回显
        this.addHelpResultsForm.employmentStatus = data.employmentStatus;
        this.addHelpResultsForm.enterpriseName = data.enterpriseName;

        this.addHelpResultsForm.implementationTime = data.implementationTime;
        res = await this.getEmploymentCategoryByStatus();
        let { employmentCategory } = data;
        employmentCategory = employmentCategory + ''; // 转字符串
        // 测试

        console.log('需要找到的就业分类', employmentCategory);
        let done = false;
        for (let i = 0; i < res.length && !done; i++) {
          if (res[i].id === employmentCategory) {
            this.addHelpResultsForm.employmentCategoryOne = res[i].title;
            this.setEmploymentCategoryTwoSelect();
            this.addHelpResultsForm.employmentCategory = res[i].profCode;
          }
          if (res[i].children) {
            // 递归查找
            for (let j = 0; j < res[i].children.length; j++) {
              if (res[i].children[j].profCode === employmentCategory) {
                this.addHelpResultsForm.employmentCategoryOne = res[i].title;
                this.setEmploymentCategoryTwoSelect();
                this.addHelpResultsForm.employmentCategoryTwo = res[i].children[j].id;
                this.addHelpResultsForm.employmentCategory = res[i].children[j].profCode;
                done = true;
                break;
              }
            }
          }
        }
      } else {
        this.addHelpResultsForm.unImplementationReason = data.unImplementationReason;
      }

      // closeMsg();
      // setTimeout(() => {
      //     this.$Message.success('获取完成');
      // }, 300);
    },

    // 按照专业代码查找路径
    getProfPathByProfCode(code, res) {
      let profList1 = res[2].result;
      let profList2 = res[1].result;
      let profList3 = res[0].result;
      let profession = code;
      let path = [];
      // 先从最底端的专业找 res[1]是专业列表2是第三个列表
      for (let i = 0; i < profList1.length; i++) {
        if (profList1[i].profCode === profession) {
          // 查找第二个列表
          for (let j = 0; j < profList2.length; j++) {
            if (profList2[j].profCode === profList1[i].parentCode) {
              path.push(profList2[j].parentCode, profList1[i].parentCode, profList1[i].profCode);
              console.log('在第三级找到了');
              return path;
            }
          }
          break;
        }
      }
      // 也可能是二级的列表
      for (let i = 0; i < profList2.length; i++) {
        if (profList2[i].profCode === profession) {
          path.push(profList2[i].parentCode, profList2[i].profCode);
          console.log('在第二级找到了');
          return path;
        }
      }
      // 也可能是一级列表
      for (let i = 0; i < profList3.length; i++) {
        if (profList3[i].profCode === profession) {
          path.push(profList3[i].profCode);
          console.log('在第一级找到了');
          return path;
        }
      }
    },

    // 根据就业状态选择就业类别 当就业状态栏变化的时候调用
    async getEmploymentCategoryByStatus() {
      this.employmentCategoryTwoLoading = true;
      this.employmentCategoryOneLoading = true;
      // 清空联动菜单
      this.employmentCategoryOne = [];
      this.employmentCategoryTwo = {
        show: true,
        list: [],
        des: '请选择就业细项'
      };
      // 清空联动菜单数值
      this.addHelpResultsForm.employmentCategoryOne = '';
      this.addHelpResultsForm.employmentCategoryTwo = '';
      // const version = new Date().getFullYear(); // 这里的version要传递年份
      // TODO 这里是一个坑 必须写死2023
      // 从cookie中拿到tableName
      // let version = Cookies.get('tableName');
      // if(!version){
      //     version = 2023;
      // }
      // if(typeof version === 'string'){
      //     version = parseInt(version);
      // }
      const version = 2023;
      let res = await getEmploymentCategory({
        version,
        dictMatch: this.addHelpResultsForm.employmentStatus
      });

      if (res.code === 200) {
        this.employmentCategoryOne = res.result ? res.result : [];
        console.log(this.employmentCategoryOne, '就业类别下拉列表第一层');
      } else {
        this.$Message.error('获取就业类别失败');
      }

      this.employmentCategoryTwoLoading = false;
      this.employmentCategoryOneLoading = false;
      return res.result;
    },

    // 当就业第一个下拉框 选中时修改这边
    setEmploymentCategoryTwoSelect() {
      // 清空联动菜单选项
      this.employmentCategoryTwo = {
        show: true,
        list: [],
        des: '请选择就业细项'
      };
      // 清空联动菜单数值
      this.addHelpResultsForm.employmentCategoryTwo = '';
      // 拿到employmentCategoryOne的选中的item
      let item = this.employmentCategoryOne.find(item => item.title === this.addHelpResultsForm.employmentCategoryOne);
      if (item) {
        // 如果item有children属性
        if (item.children) {
          this.employmentCategoryTwo = {
            show: true,
            list: item.children,
            des: '请选择就业细项'
          };
        } else {
          this.employmentCategoryTwo = {
            show: false,
            list: [],
            des: '无就业细项'
          };
        }
        console.log('就业类别下拉选项第二层及', this.employmentCategoryTwo);
      }
    },

    // 上传前的数据整理
    basicDataFormat() {
      let basicRequest = {
        ...this.essentialInformationForm, // 基本信息的十四个数据
        ...this.addHelpResultsForm, // 帮扶结果的五个数据
        helpCategory: this.helpCategory.join(','), // 帮扶类型 数组
        ...this.addHelpResultsForm, // 添加帮扶结果 如果选择已落实 六个表单 如果选择未落实 两个表单
        ...this.addHelpersForm, // 添加帮扶人的三个表单
        ...this.dataCheckConditionForm // 数据核对情况的两个
      };
      // 处理数据核对情况
      // if (!this.dataCheckConditionSelect.includes(basicRequest.dataCheckCondition)) {
      //     // 如果选择的值不在下拉框内 赋给默认值
      //     basicRequest.dataCheckCondition = '困难群体毕业生';
      // }
      console.log(basicRequest.dataCheckCondition);
      // 处理帮扶结果
      if (this.addHelpResultsForm.helpResult === '1') {
        // 选择已落实毕业去向的时候 删掉多余表单
        // 包括未落实原因 以及联动的就业分类的两个 目前只提交一个
        delete basicRequest.unImplementationReason;
        delete basicRequest.employmentCategoryOne;
        delete basicRequest.employmentCategoryTwo;
      } else {
        // 删除除结果和umImplementationReason以外的字段
        Object.keys(this.addHelpResultsForm).forEach(keysName => {
          if (keysName !== 'helpResult' && keysName !== 'unImplementationReason') {
            delete basicRequest[keysName];
          }
        });
      }

      // 处理性别的数据类型
      basicRequest.sex = parseInt(basicRequest.sex);
      // helpResult也要int
      basicRequest.helpResult = parseInt(basicRequest.helpResult);

      // 处理时间的格式
      basicRequest.birthday = moment(basicRequest.birthday).format('YYYY-MM-DD') === 'Invalid date' ? '' : moment(basicRequest.birthday).format('YYYY-MM-DD');
      basicRequest.graduationTime = moment(basicRequest.graduationTime).format('YYYY-MM-DD') === 'Invalid date' ? '' : moment(basicRequest.graduationTime).format('YYYY-MM-DD');
      basicRequest.implementationTime = moment(basicRequest.implementationTime).format('YYYY-MM-DD') === 'Invalid date' ? '' : moment(basicRequest.implementationTime).format('YYYY-MM-DD');

      // 民族 专业 学历 政治面貌 需要代码
      // 需要进行反映射的属性
      // basicRequest.educationalLevel = this.getTitleByValue(this.formTypeMap.eduLevelType, basicRequest.educationalLevel);
      // basicRequest.college = getTitleByValue(this.formTypeMap.college, basicRequest.college);
      // basicRequest.profession = basicRequest.profession[basicRequest.profession.length - 1];

      return basicRequest;
    },
    heartListFormat() {
      return this.listOfHeartToHeartTalks.map(item => {
        return {
          heartTalkContext: item.conversation,
          heartTalkTime: moment(item.date).format('YYYY-MM-DD HH:mm:ss'),
          heartTalkPlace: item.place
        };
      });
    },
    recommendListFormat() {
      return this.recommendedPostList.map(item => {
        return {
          // 建立映射
          recommendEnterpriseName: item.companyName,
          recommendMobile: item.contactWay,
          recommendPeopleName: item.unitContact,
          recommendPositionName: item.nameOfThePost,
          recommendSign: item.whetherToSignOrNot === '' ? 0 : parseInt(item.whetherToSignOrNot),
          recommendTime: moment(item.recommendedTime).format('YYYY-MM-DD')
        };
      });
    },
    employListFormat() {
      return this.participationInEmploymentPromotionActivitiesList.map(item => {
        return {
          employPro: item.nameOfActivity,
          employProTime: moment(item.participationTime).format('YYYY-MM-DD HH:mm:ss')
        };
      });
    },
    otherFormat() {
      let other = '';
      if (this.otherMeasuresList.length > 0) {
        other = this.otherMeasuresList[0].otherMeasuresText;
      }
      return other;
    },

    // 添加页面采用这个
    async handleSubmit() {
      let valid = await this.$refs.addHelpersRef.validate();
      let result = true;
      if (!valid && (this.dataCheckConditionForm.knqtbj != 0 ) ) {
        this.$Message.error('请检查帮扶人信息');
        result = false;
      }
      valid = await this.$refs.addHelpResultsRef.validate();
      if (!valid) {
        this.$Message.error('请检查帮扶结果信息');
        result = false;
      }
      valid = await this.$refs.essentialInformationRef.validate();
      if (!valid) {
        this.$Message.error('请检查基础信息');
        result = false;
      }

      if (this.helpCategory.length === 0) {
        this.$Message.error('请选择帮扶类别');
        result = false;
      }
      if (!result) {
        return;
      }

      let data = {
        basicRequest: this.basicDataFormat(),
        heartList: this.heartListFormat(),
        recommendList: this.recommendListFormat(),
        employList: this.employListFormat(),
        other: this.otherFormat()
      };

      try {
        let res = await addHardshipSupport(data);

        if (res.code === 200) {
          this.$Message.success('提交成功');
          this.goBack();
        } else {
          this.$Message.error('提交失败');
        }
      } catch (e) {
        this.$Message.error('网络错误');
      }
    },

    // 谈心谈话
    showModel(type) {
      // 如果type存在 说明是编辑
      if (type || type === 0) {
        this.heartToHeartTalkEdit = type;
        this.heartToHeartTalkForm = copy(this.listOfHeartToHeartTalks[type]);
        this.heartToHeartTalk = true;
      } else {
        // 添加
        // 限制最大长度只能是3

        this.heartToHeartTalk = true;
      }
    },
    deleteAConversation(type) {
      this.listOfHeartToHeartTalks.splice(type, 1);
    },
    // 谈心谈话提交
    submitAHeartToHeartTalk() {
      if (this.heartToHeartTalkForm.date === '') {
        // 设置为当前日期
        this.heartToHeartTalkForm.date = moment().format('YYYY-MM-DD HH:mm:ss');
      }
      if (this.heartToHeartTalkEdit || this.heartToHeartTalkEdit === 0) {
        this.listOfHeartToHeartTalks[this.heartToHeartTalkEdit] = copy(this.heartToHeartTalkForm);
        this.heartToHeartTalkEdit = null;
      } else {
        this.listOfHeartToHeartTalks.push(this.heartToHeartTalkForm);
      }
      this.heartToHeartTalk = false;
    },

    // 参加就业促进活动
    showModel1(type) {
      console.log(type);

      if (type || type === 0) {
        this.participationInEmploymentPromotionActivitiesEdit = type;
        this.participationInEmploymentPromotionActivitiesForm = copy(this.participationInEmploymentPromotionActivitiesList[type]);
        this.participationInEmploymentPromotionActivities = true;
      } else {
        this.participationInEmploymentPromotionActivities = true;
      }
    },
    deleteAConversation1(type) {
      this.participationInEmploymentPromotionActivitiesList.splice(type, 1);
    },

    // 参加就业促进活动提交
    employmentPromotionActivities() {
      if (this.participationInEmploymentPromotionActivitiesForm.participationTime === '') {
        // 设置为当前日期
        this.participationInEmploymentPromotionActivitiesForm.participationTime = moment().format('YYYY-MM-DD HH:mm:ss');
      }

      if (this.participationInEmploymentPromotionActivitiesEdit || this.participationInEmploymentPromotionActivitiesEdit === 0) {
        this.participationInEmploymentPromotionActivitiesList[this.participationInEmploymentPromotionActivitiesEdit] = copy(this.participationInEmploymentPromotionActivitiesForm);
        this.participationInEmploymentPromotionActivitiesEdit = null;
      } else {
        this.participationInEmploymentPromotionActivitiesList.push(this.participationInEmploymentPromotionActivitiesForm);
      }
      this.participationInEmploymentPromotionActivities = false;
    },

    // 推荐岗位
    showModel2(type) {
      console.log(type);
      if (type || type === 0) {
        this.recommendedPostEdit = type;
        this.recommendedPostForm = copy(this.recommendedPostList[type]);
        this.recommendedPost = true;
      } else {
        this.recommendedPost = true;
      }
    },
    deleteAConversation2(type) {
      this.recommendedPostList.splice(type, 1);
    },
    // 推荐岗位提交
    recommendedPostSubmission() {
      if (this.recommendedPostForm.recommendedTime === '') {
        this.recommendedPostForm.recommendedTime = moment().format('YYYY-MM-DD HH:mm:ss');
      }

      if (this.recommendedPostEdit || this.recommendedPostEdit === 0) {
        this.recommendedPostList[this.recommendedPostEdit] = copy(this.recommendedPostForm);
        this.recommendedPostEdit = null;
      } else {
        this.recommendedPostList.push(this.recommendedPostForm);
      }
      this.recommendedPost = false;
    },

    // 其他帮扶措施
    showModel3(type) {
      if (type || type === 0) {
        this.otherMeasuresEdit = type;
        this.otherMeasuresText = copy(this.otherMeasuresList[type].otherMeasuresText);
        this.otherMeasures = true;
      } else {
        if (this.otherMeasuresList.length >= 1) return this.$Message.error('只能添加一条记录');
        this.otherMeasures = true;
      }
    },
    deleteAConversation3(index) {
      this.otherMeasuresList.splice(index, 1);
    },
    // 其他帮扶措施提交
    otherAssistanceMeasuresToSubmit() {
      if (this.otherMeasuresEdit || this.otherMeasuresEdit === 0) {
        this.otherMeasuresList[this.otherMeasuresEdit].otherMeasuresText = this.otherMeasuresText;
        this.otherMeasuresText = '';
      } else {
        this.otherMeasuresList.push({
          otherMeasuresText: this.otherMeasuresText
        });
        this.otherMeasuresText = '';
      }
      this.otherMeasures = false;
    },

    // </editor-fold>

    //<editor-fold desc="修改帮扶">
    // 处理回显
    async handleEcho(data) {
      console.log(data, 521);

      //  暂时基础数据来自生源表
      //<editor-fold desc="处理基础数据">
      let basicData = data.basic;
      Object.keys(this.essentialInformationForm).forEach(key => {
        this.essentialInformationForm[key] = basicData[key] ?? '';
      });
      // 处理性别
      this.essentialInformationForm.sex = basicData.sex + '';
      // 单独判断一下学历层次的数值类型 如果学历层次和formTypeMap[2]的列表中的对象的title相等
      // 那么就将学历层次的值设置为这个对象的value
      /*for (let i = 0; i < this.formTypeMap.eduLevelType.length; i++) {
          if (this.formTypeMap.eduLevelType[i].title === basicData.educationalLevel) {
              this.essentialInformationForm.educationalLevel = this.formTypeMap.eduLevelType[i].value;
              break;
          }
      }*/
      this.essentialInformationForm.educationalLevel = basicData.educationalLevel;
      this.essentialInformationForm.profession = basicData.profession;
      // 处理帮扶类别
      this.helpCategory = basicData.helpCategory;
      // 处理帮扶人
      this.addHelpersForm = {
        helperName: basicData.helperName,
        helperPhone: basicData.helperPhone,
        helperJob: basicData.helperJob
      };

      // 处理数据不一致
      this.dataCheckConditionForm = {
        dataCheckCondition: basicData.dataCheckCondition,
        dataCheckOther: basicData.dataCheckOther
      };

      this.dataCheckConditionForm.knqtbj = basicData.knqtbj;
      /*// 处理专业
      if (this.essentialInformationForm.educationalLevel) {
          let profession = this.essentialInformationForm.profession;
          let res = await this.getProfessionLevelOneByEduLevel();
          this.essentialInformationForm.profession = this.getProfPathByProfCode(profession, res);
      } else {
          this.essentialInformationForm.profession = [];
      }*/

      // 处理就业分类
      // 判断需不需要做就业类别的回显
      this.addHelpResultsForm.helpResult = basicData.helpResult ?? '0';
      this.addHelpResultsForm.helpResult += '';
      if (this.addHelpResultsForm.helpResult === '1') {
        this.addHelpResultsForm.enterpriseName = basicData.enterpriseName;
        this.addHelpResultsForm.implementationTime = basicData.implementationTime;
        // 如果存在就业状态 则继续查询就业类别
        if (basicData.employmentStatus) {
          this.addHelpResultsForm.employmentStatus = basicData.employmentStatus;
          let res = await this.getEmploymentCategoryByStatus();
          let employmentCategory = basicData.employmentCategory;
          let done = false;
          for (let i = 0; i < res.length && !done; i++) {
            if (res[i].profCode === employmentCategory) {
              this.addHelpResultsForm.employmentCategoryOne = res[i].title;
              this.addHelpResultsForm.employmentCategory = res[i].profCode;
              this.setEmploymentCategoryTwoSelect();
            }
            if (res[i].children) {
              // 递归查找
              for (let j = 0; j < res[i].children.length; j++) {
                if (res[i].children[j].profCode === employmentCategory) {
                  this.addHelpResultsForm.employmentCategoryOne = res[i].title;
                  this.setEmploymentCategoryTwoSelect();
                  this.addHelpResultsForm.employmentCategoryTwo = res[i].children[j].id;
                  this.addHelpResultsForm.employmentCategory = res[i].children[j].profCode;
                  done = true;
                  break;
                }
              }
            }
          }
        }
      } else {
        this.addHelpResultsForm.unImplementationReason = basicData.unImplementationReason;
      }

      //</editor-fold>

      //<editor-fold desc="处理谈心谈话">
      let heartList = data.heartList ?? [];
      // heartList的数据结构是item 将其转为heartToHeartTalkForm 存入this.listOfHeartToHeartTalks
      this.listOfHeartToHeartTalks = heartList.map(item => {
        return {
          place: item.heartTalkPlace,
          date: item.heartTalkTime,
          conversation: item.heartTalkContext,
          id: item.id,
          createTime: item.createTime
        };
      });
      //</editor-fold>

      //<editor-fold desc="参加就业活动">
      let employList = data.employList ?? [];
      this.participationInEmploymentPromotionActivitiesList = employList.map(item => {
        return {
          nameOfActivity: item.employPro,
          participationTime: item.employProTime,
          id: item.id,
          createTime: item.createTime
        };
      });
      //</editor-fold>

      //<editor-fold desc="处理推荐岗位">
      let recommendList = data.recommendList ?? [];
      this.recommendedPostList = recommendList.map(item => {
        return {
          companyName: item.recommendEnterpriseName,
          contactWay: item.recommendMobile,
          unitContact: item.recommendPeopleName,
          nameOfThePost: item.recommendPositionName,
          whetherToSignOrNot: item.recommendSign + '',
          recommendedTime: item.recommendTime,
          id: item.id,
          createTime: item.createTime
        };
      });
      //</editor-fold>

      //<editor-fold desc="处理其他">
      let other = data.other;
      if (other) {
        this.otherMeasuresList = [
          {
            otherMeasuresText: other.other,
            createTime: other.createTime
          }
        ];
        this.otherId = other.id;
      }
      this.dataCheckConditionForm = JSON.parse(JSON.stringify(this.dataCheckConditionForm));
    },

    // 编辑基础信息
    async editBasic() {
      let valid = await this.$refs.addHelpersRef.validate();
      let result = true;
      if (!valid  && this.dataCheckConditionForm.knqtbj!=0) {
        this.$Message.error('请检查帮扶人信息');
        result = false;
      }

      if (!result) {
        return;
      }

      let data = this.basicDataFormat();
      let params = {
        ...data,
        id: this.id
      }
      try {
        let res = await updateHardshipSupport(JSON.stringify(params));
        if (res.code === 200) {
          this.$Message.success('修改成功');
          this.goBack();
        }
      } catch (e) {
        this.$Message.error('网络错误');
      }
    },
    // 删除谈心谈话
    async deleteHeart(id) {
      this.$Modal.confirm({
        title: '删除谈心谈话',
        content: '确定删除此条谈心谈话吗？',
        onOk: async () => {
          let res = await deleteHeartTalk({
            heartId: id
          });
          if (res.code === 200) {
            this.$Message.success('删除成功');
            this.listOfHeartToHeartTalks = this.listOfHeartToHeartTalks.filter(item => item.id !== id);
          } else {
            this.$Message.error('删除失败');
          }
        }
      });
    },
    // 删除推荐岗位
    async deleteRecommend(id) {
      this.$Modal.confirm({
        title: '删除推荐岗位',
        content: '确定删除此条推荐岗位吗？',
        onOk: async () => {
          let res = await deleteRecommend({
            recommendId: id
          });
          if (res.code === 200) {
            this.$Message.success('删除成功');
            this.recommendedPostList = this.recommendedPostList.filter(item => item.id !== id);
          } else {
            this.$Message.error('删除失败');
          }
        }
      });
    },
    // 删除就业促进活动
    async deleteEmploy(id) {
      this.$Modal.confirm({
        title: '删除参加就业促进活动',
        content: '确定删除此条参加就业促进活动吗？',
        onOk: async () => {
          let res = await deleteEmploy({
            employId: id
          });
          if (res.code === 200) {
            this.$Message.success('删除成功');
            this.participationInEmploymentPromotionActivitiesList = this.participationInEmploymentPromotionActivitiesList.filter(item => item.id !== id);
          } else {
            this.$Message.error('删除失败');
          }
        }
      });
    },
    // 删除其他
    async deleteOther(id) {
      this.$Modal.confirm({
        title: '删除其他帮扶措施',
        content: '确定删除此条其他帮扶措施吗？',
        onOk: async () => {
          let res = await deleteOther({
            otherId: id
          });
          if (res.code === 200) {
            this.$Message.success('删除成功');
            this.otherMeasuresList = [];
            this.otherId = '0';
          } else {
            this.$Message.error('删除失败');
          }
        }
      });
    },

    // 修改或者添加谈心谈话
    async editHeart() {
      if (this.heartToHeartTalkForm.id) {
        // 修改
        let date = this.heartToHeartTalkForm.date ? moment(this.heartToHeartTalkForm.date).format('YYYY-MM-DD HH:mm:ss') : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          heartTalkContext: this.heartToHeartTalkForm.conversation,
          heartTalkTime: date,
          heartTalkPlace: this.heartToHeartTalkForm.place
        };
        let res = await editHeartTalk({
          ...data,
          heartId: this.heartToHeartTalkForm.id
        });
        if (res.code === 200) {
          this.$Message.success('修改成功');
          // 转成表单的
          this.heartToHeartTalkForm.conversation = res.result.heartTalkContext;
          this.heartToHeartTalkForm.date = res.result.heartTalkTime;
          this.heartToHeartTalkForm.place = res.result.heartTalkPlace;
          this.heartToHeartTalkForm.id = res.result.id;
          this.submitAHeartToHeartTalk();
        } else {
          this.$Message.error('修改失败');
        }
      } else {
        let date = this.heartToHeartTalkForm.date ? moment(this.heartToHeartTalkForm.date).format('YYYY-MM-DD HH:mm:ss') : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          heartTalkContext: this.heartToHeartTalkForm.conversation,
          heartTalkTime: date,
          heartTalkPlace: this.heartToHeartTalkForm.place,
          needyId: this.id
        };
        let res = await addHeartTalk(data);
        if (res.code === 200) {
          this.$Message.success('添加成功');
          // 转成表单的
          this.heartToHeartTalkForm.conversation = res.result.heartTalkContext;
          this.heartToHeartTalkForm.date = res.result.heartTalkTime;
          this.heartToHeartTalkForm.place = res.result.heartTalkPlace;
          this.heartToHeartTalkForm.id = res.result.id;
          this.submitAHeartToHeartTalk();
        } else {
          this.$Message.error('添加失败');
        }
      }
    },
    // 修改或添加推荐岗位
    async editRecommend() {
      if (this.recommendedPostForm.id) {
        // 修改
        let date = this.recommendedPostForm.recommendedTime ? moment(this.recommendedPostForm.recommendedTime).format('YYYY-MM-DD HH:mm:ss') : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          recommendEnterpriseName: this.recommendedPostForm.companyName,
          recommendMobile: this.recommendedPostForm.contactWay,
          recommendPeopleName: this.recommendedPostForm.unitContact,
          recommendPositionName: this.recommendedPostForm.nameOfThePost,
          recommendSign: this.recommendedPostForm.whetherToSignOrNot === '' ? 0 : parseInt(this.recommendedPostForm.whetherToSignOrNot),
          recommendTime: date
        };
        let res = await editRecommend({
          ...data,
          recommendId: this.recommendedPostForm.id
        });
        if (res.code === 200) {
          this.$Message.success('修改成功');
          // 转成表单的
          this.recommendedPostForm.companyName = res.result.recommendEnterpriseName;
          this.recommendedPostForm.contactWay = res.result.recommendMobile;
          this.recommendedPostForm.unitContact = res.result.recommendPeopleName;
          this.recommendedPostForm.nameOfThePost = res.result.recommendPositionName;
          this.recommendedPostForm.whetherToSignOrNot = res.result.recommendSign + '';
          this.recommendedPostForm.recommendedTime = res.result.recommendTime;
          this.recommendedPostForm.id = res.result.id;
          this.recommendedPostSubmission();
        } else {
          this.$Message.error('修改失败');
        }
      } else {
        let date = this.recommendedPostForm.recommendedTime ? moment(this.recommendedPostForm.recommendedTime).format('YYYY-MM-DD HH:mm:ss') : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          recommendEnterpriseName: this.recommendedPostForm.companyName,
          recommendMobile: this.recommendedPostForm.contactWay,
          recommendPeopleName: this.recommendedPostForm.unitContact,
          recommendPositionName: this.recommendedPostForm.nameOfThePost,
          recommendSign: this.recommendedPostForm.whetherToSignOrNot === '' ? 0 : parseInt(this.recommendedPostForm.whetherToSignOrNot),
          recommendTime: date,
          needyId: this.id
        };
        let res = await addRecommend(data);
        if (res.code === 200) {
          this.$Message.success('添加成功');
          // 转成表单的
          this.recommendedPostForm.companyName = res.result.recommendEnterpriseName;
          this.recommendedPostForm.contactWay = res.result.recommendMobile;
          this.recommendedPostForm.unitContact = res.result.recommendPeopleName;
          this.recommendedPostForm.nameOfThePost = res.result.recommendPositionName;
          this.recommendedPostForm.whetherToSignOrNot = res.result.recommendSign + '';
          this.recommendedPostForm.recommendedTime = res.result.recommendTime;
          this.recommendedPostForm.id = res.result.id;
          this.recommendedPostSubmission();
        }
      }
    },

    // 修改或添加就业促进活动
    async editEmploy() {
      if (this.participationInEmploymentPromotionActivitiesForm.id) {
        // 修改
        let date = this.participationInEmploymentPromotionActivitiesForm.participationTime
            ? moment(this.participationInEmploymentPromotionActivitiesForm.participationTime).format('YYYY-MM-DD HH:mm:ss')
            : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          employPro: this.participationInEmploymentPromotionActivitiesForm.nameOfActivity,
          employProTime: date
        };
        let res = await editEmploy({
          ...data,
          employId: this.participationInEmploymentPromotionActivitiesForm.id
        });
        if (res.code === 200) {
          this.$Message.success('修改成功');
          // 转成表单的
          this.participationInEmploymentPromotionActivitiesForm.nameOfActivity = res.result.employPro;
          this.participationInEmploymentPromotionActivitiesForm.participationTime = res.result.employProTime;
          this.participationInEmploymentPromotionActivitiesForm.id = res.result.id;
          this.employmentPromotionActivities();
        } else {
          this.$Message.error('修改失败');
        }
      } else {
        let date = this.participationInEmploymentPromotionActivitiesForm.participationTime
            ? moment(this.participationInEmploymentPromotionActivitiesForm.participationTime).format('YYYY-MM-DD HH:mm:ss')
            : moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
        let data = {
          employPro: this.participationInEmploymentPromotionActivitiesForm.nameOfActivity,
          employProTime: date,
          needyId: this.id
        };
        let res = await addEmploy(data);
        if (res.code === 200) {
          this.$Message.success('添加成功');
          this.participationInEmploymentPromotionActivitiesForm.nameOfActivity = res.result.employPro;
          this.participationInEmploymentPromotionActivitiesForm.participationTime = res.result.employProTime;
          this.participationInEmploymentPromotionActivitiesForm.id = res.result.id;
          this.employmentPromotionActivities();
        }
      }
    },

    // 添加或修改其他
    async editOther() {
      if (this.otherId !== '0') {
        // 修改
        let res = await editOther({
          other: this.otherMeasuresText,
          otherId: this.otherId
        });
        if (res.code === 200) {
          this.$Message.success('修改成功');
          this.otherAssistanceMeasuresToSubmit();
        } else {
          this.$Message.error('修改失败');
        }
      } else {
        // 创建
        let res = await addOther({
          other: this.otherMeasuresText,
          needyId: this.id
        });
        if (res.code === 200) {
          this.$Message.success('添加成功');
          this.otherId = res.result.id;
          this.otherMeasuresEdit = null;
          this.otherAssistanceMeasuresToSubmit();
        } else {
          this.$Message.error('添加失败');
        }
      }
    },
    //</editor-fold>
    goBack() {
      console.log(this.pageIndex);
      this.$router.replace({
        path: '/hardshipSupport',
        query:{
          pageIndex:this.pageIndex
        }
      });
    }
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.onRestWindow);
    // 全局销毁Message
    this.$Message.destroy();
  }
};
</script>

<style scoped lang="less">
::v-deep .ivu-checkbox-checked .ivu-checkbox-inner {
  background-color: #6c6c6c;
  border: none;
}

::v-deep .ivu-checkbox-focus {
  box-shadow: none;
}
</style>
<style>
.ivu-form-item-label {
  /* width: 100px !important; */
  /* text-align: left !important; */
}

.ivu-form-item-content {
  /* margin-left: 100px !important; */
}

.form-item-width {
  width: 450px;
}

.title {
  height: 40px;
  border-bottom: 1px solid #eef1f7;
}

.head-box {
  height: calc(100% - 60px)
}

.head-box01 {
  height: 60px;
  border-bottom: 1px solid #eef1f7
}

.w400 {
  width: 400px
}

.w25 {
  width: 25px;
}

.color-size {
  color: #000000;
  font-size: 14px
}

.bl2 {
  border-left: 2px solid #e9e9e9;
  min-height: 100px
}

.w900 {
  width: 900px;
  background-color: #eaf4ff;
  border-radius: 6px
}

.h40 {
  height: 40px;
  border-bottom: 1px solid #e8edf4
}

.img01 {
  margin-left: 3px;
  width: 20px
}

.label01 {
  color: #000000;
  font-size: 14px
}

.class01 {
  border-left: 2px solid #e9e9e9;
  min-height: 100px
}

.label02 {
  font-size: 12px;
  color: #b5b5b5
}

.class02 {
  width: 900px;
  background-color: #eaf4ff;
  border-radius: 6px
}

.w300 {
  width: 300px
}

.w600 {
  width: 600px
}

.w200 {
  width: 200px
}

.w100 {
  width: 100px
}

.w700 {
  width: 700px
}

/* .class03 {
    style="height: 40px; border-bottom: 1px solid #e8edf4"
} */
</style>
